/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Genera_Tabla.java
 *
 * Created on 14-oct-2012, 21:14:17
 */
package conversorautmoata.vistas;

import conversorautmoata.Alfabeto;
import conversorautmoata.Nodo;
import java.util.List;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import org.jdesktop.swingx.JXTable;

/**
 *
 * @author JorgeLuis
 */
public class Genera_Tabla extends javax.swing.JDialog {

    /** Creates new form Genera_Tabla */
    public Genera_Tabla(java.awt.Frame parent, boolean modal, List<Nodo> nodos, List<Alfabeto> alfabetos) {
        super(parent, modal);
        this.nodos = nodos;
        this.alfabetos = alfabetos;
        Alfabeto alfabeto = new Alfabeto();
        alfabeto.setNombre("e");
        this.alfabetos.add(alfabeto);
        initComponents();
        this.setLocationRelativeTo(null);
        this.setVisible(true);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        panel1 = new org.edisoncor.gui.panel.Panel();
        btn_guardar = new org.edisoncor.gui.button.ButtonPopup();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        panel1.setColorPrimario(new java.awt.Color(97, 129, 197));
        panel1.setColorSecundario(new java.awt.Color(97, 129, 197));

        btn_guardar.setText("Comenzar");
        btn_guardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_guardarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panel1Layout = new javax.swing.GroupLayout(panel1);
        panel1.setLayout(panel1Layout);
        panel1Layout.setHorizontalGroup(
            panel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel1Layout.createSequentialGroup()
                .addGap(149, 149, 149)
                .addComponent(btn_guardar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(170, Short.MAX_VALUE))
        );
        panel1Layout.setVerticalGroup(
            panel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel1Layout.createSequentialGroup()
                .addGap(28, 28, 28)
                .addComponent(btn_guardar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(249, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(panel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(panel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void btn_guardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_guardarActionPerformed
    genera_tabla();
    // TODO add your handling code here:
}//GEN-LAST:event_btn_guardarActionPerformed
    /**
     * @param args the command line arguments
     */
//    public static void main(String args[]) {
//        /* Set the Nimbus look and feel */
//        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
//        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
//         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
//         */
//        try {
//            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
//                if ("Nimbus".equals(info.getName())) {
//                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
//                    break;
//                }
//            }
//        } catch (ClassNotFoundException ex) {
//            java.util.logging.Logger.getLogger(Genera_Tabla.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (InstantiationException ex) {
//            java.util.logging.Logger.getLogger(Genera_Tabla.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (IllegalAccessException ex) {
//            java.util.logging.Logger.getLogger(Genera_Tabla.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
//            java.util.logging.Logger.getLogger(Genera_Tabla.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        }
//        //</editor-fold>
//
//        /* Create and display the dialog */
//        java.awt.EventQueue.invokeLater(new Runnable() {
//
//            public void run() {
//                Genera_Tabla dialog = new Genera_Tabla(new javax.swing.JFrame(), true);
//                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
//
//                    @Override
//                    public void windowClosing(java.awt.event.WindowEvent e) {
//                        System.exit(0);
//                    }
//                });
//                dialog.setVisible(true);
//            }
//        });
//    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private org.edisoncor.gui.button.ButtonPopup btn_guardar;
    private org.edisoncor.gui.panel.Panel panel1;
    // End of variables declaration//GEN-END:variables

    public void genera_tabla() {
        tabla_transicion = new String[nodos.size()][alfabetos.size()];
        for (int i = 0; i < nodos.size(); i++) {
            for (int j = 0; j < alfabetos.size(); j++) {

                tabla_transicion[i][j] = JOptionPane.showInputDialog(null, "Ingrese Nodo para transicion en:" + alfabetos.get(j).getNombre());

            }
        }
    }
    JXTable tabla;

    public void disenio_tabla(JScrollPane panel, JXTable tabla) {
        panel.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
        panel.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
        panel.setViewportView(tabla);
        panel1.add(panel);
    }
    String tabla_transicion[][];
    List<Alfabeto> alfabetos;
    List<Nodo> nodos;

    public List<Alfabeto> getAlfabetos() {
        return alfabetos;
    }

    public void setAlfabetos(List<Alfabeto> alfabetos) {
        this.alfabetos = alfabetos;
    }

    public List<Nodo> getNodos() {
        return nodos;
    }

    public void setNodos(List<Nodo> nodos) {
        this.nodos = nodos;
    }

    public JXTable getTabla() {
        return tabla;
    }

    public void setTabla(JXTable tabla) {
        this.tabla = tabla;
    }

    public String[][] getTabla_transicion() {
        return tabla_transicion;
    }

    public void setTabla_transicion(String[][] tabla_transicion) {
        this.tabla_transicion = tabla_transicion;
    }
}
